import time
import logzero
from logzero import logger
class tic_toc(object):
    def __init__(self, comment):
        self.comment = comment

    def __enter__(self): 
        self.st_time = time.time()
        logger.info(self.comment)

    def __exit__(self,a,b,c):
        ed_time = time.time()
        logger.info("耗时：{:.2f}s\n".format(ed_time-self.st_time))